package com.material.vtool.wechat.service;

import com.google.common.collect.Maps;

import java.util.Map;

public class WeixinServiceMap {

    static Map<String, WeixinServiceDL> wsMap = Maps.newHashMapWithExpectedSize(30);

    public synchronized static void putWeixinService(String miniCode, WeixinServiceDL weixinService) { //添加同步块
        if(!wsMap.containsKey(miniCode)){
            wsMap.put(miniCode, weixinService);
        }
    }

    public static WeixinServiceDL getWeixinService(String miniCode) {
        WeixinServiceDL weixinService=null;
        if(wsMap.containsKey(miniCode)){
            weixinService = wsMap.get(miniCode);
        }
        return weixinService;
    }

    public static Map<String, WeixinServiceDL> getWeixinServiceMap() {
        return wsMap;
    }

    public static void removeWeixinService(String miniCode) {
        if(wsMap.containsKey(miniCode)){
            wsMap.remove(miniCode);
        }
    }
}
